<template>
	<!-- 考核录入 -->
	<view class="flex-col h100">
		<view class="">
			<u-navbar title="考核录入" :placeholder="true" leftIconColor="#fff" titleStyle="color: #fff" bgColor="#2172FC" :autoBack="true">
				<template #right>
					<u-icon name="plus" color="#fff" size="25" @click="addWork"></u-icon>
					<u-icon name="hourglass" color="#fff" size="25" @click="openPopup"></u-icon>
				</template>
			</u-navbar>
		</view>
		<view class="p-10">
			<template v-if="list.length > 0">
				<view class="card" v-for="(item,index) in list" :index="index">
					<view class="flex m-between">
						<view class="name fw">
							<text>被考核人:</text>{{item.examPeopleName}}
						</view>
						<view class="grade fw"> 被考核岗位:{{item.examJobName}}
						</view>
					</view>
					<view class="flex m-between m-t-8">
						<view class="post"> <text>被考核单位:</text> {{item.examDeptName}}
						</view>
						<view class="pro"> 考核日期: {{item.examTime }}
						</view>
					</view>
					<view class="des m-t-8 fw" style="color: "> 扣分分值: <u-tag :text="item.fineScore" size="mini" type="error"></u-tag>
					</view>
					<view class="date m-t-8"> 扣分原因：{{item.mainReason}}
					</view>
				</view>
			</template>
			<u-empty v-else mode="data">
			</u-empty>
		</view>
	</view>
	<!-- 筛选popup -->
	<u-popup :show="showPopup" class="my-popup" :closeOnClickOverlay="true" mode="right" @close="closePopup">
		<view class="p-20">
			<my-forms ref="dynamicForm" :model="queryParams" :formItem="formData"></my-forms>
			<view class="flex m-between">
				<button type="error" size="mini" @click="reset">重置</button>
				<button type="primary" size="mini" @click="submit">确定</button>
			</view>
		</view>
	</u-popup>
	<u-back-top :scroll-top="scrollTop" top="600"></u-back-top>
</template>
<script setup>
	import {
		reactive,
		ref,
		computed
	} from "vue";
	import {
		onShow,
	} from '@dcloudio/uni-app'
	import useList from '@/hooks/useList.js'
	import {
		pageExam
	} from '@/api/exam.js'
	let dynamicForm = ref(null),
		queryParams = reactive({
			needCount: 1,
			pageNum: 1,
			pageSize: 10,
			time: [],
			startTime: '',
			endTime: '',
		}),
		formData = computed(() => {
			return [{
				label: '被考核人员',
				prop: 'examPeopleName'
			}, {
				itemType: 'select',
				type: 'GETpostList',
				label: '考核部门类型',
				prop: 'examJob'
			}, {
				itemType: 'date',
				type: 'daterange',
				label: '考核时间',
				prop: 'time'
			}]
		})
	// 查询
	const submit = () => {
		if (queryParams.time) {
			queryParams.startTime = queryParams.time[0]
			queryParams.endTime = queryParams.time[1]
			delete queryParams.time
		}
		getListData()
		showPopup.value = false
	}
	const {
		getListData,
		list,
		scrollTop,
		showPopup,
		openPopup,
		closePopup,
		reset
	} = useList({
		queryParams,
		api: {
			page: pageExam
		}
	})
	// 新增任务
	const addWork = () => {
		uni.navigateTo({
			url: '/pages/professional/examine/enter/add'
		})
	}
	onShow(() => {
		getListData()
	})
</script>
<style lang="scss" scoped>
	.badge {
		position: absolute;
		top: 0;
		left: 0;
	}
</style>